//
//  CompetitionTableViewCell.m
//  CoolRollerSkating
//
//  Created by 谢伟康 on 15/11/11.
//  Copyright © 2015年 Coollang. All rights reserved.
//

#import "CompetitionTableViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+CM_ShowImage.h"

@interface CompetitionTableViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *rankingLabel;
@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *signatureLabel;
@property (weak, nonatomic) IBOutlet UILabel *kilometerLabel;
@property (weak, nonatomic) IBOutlet UILabel *unitLabel;
@property (weak, nonatomic) IBOutlet UIView *levelView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomContraitLevel;

@end

@implementation CompetitionTableViewCell

- (void)configureCompetitionCellByModel:(RankModel *)modal indexPath:(NSIndexPath *)indexPath rankModeType:(RankModeType)type {
    switch (type) {
        case RankModeTypeSwings:
            self.unitLabel.text = NSLocalizedString(@"Sport.Unit.Shots", nil);
            self.kilometerLabel.text = modal.totalCount;
            break;
        case RankModeTypeMaxSpeed:
            self.unitLabel.text = @"km/h";
            self.kilometerLabel.text = modal.maxspeed;
            break;
        case RankModeTypeAvgScore:
            self.unitLabel.text = NSLocalizedString(@"Unit.Score", nil);
            self.kilometerLabel.text = modal.maxScore;
            break;
    }
    
    self.rankingLabel.text = [NSString stringWithFormat:@"%ld",(long)(indexPath.row + 3)];
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:modal.headIcon] placeholderImage:[UIImage imageNamed:@"competition_icon_defaulImage"]];
    
    self.nameLabel.text = modal.userName;
    self.signatureLabel.text = modal.signature;
}

#pragma mark - IBAction

- (IBAction)showImage:(id)sender {
    [self.headImage showImage];
}


@end
